﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace iBookstore.Models
{
    //public class SampleData : DropCreateDatabaseIfModelChanges<iBookstoreEntities>
    public class SampleData : DropCreateDatabaseAlways<iBookstoreEntities>
    {
        protected override void Seed(iBookstoreEntities context)
        {
            var genres = new List<Genre>
            {
                new Genre { Name = "Animal & Nature" },
                new Genre { Name = "Biographies" },
                new Genre { Name = "Cartoons" },
                new Genre { Name = "Children" },
                new Genre { Name = "Comicbooks" },
                new Genre { Name = "Data & IT" },
                new Genre { Name = "Detective Stories" },
                new Genre { Name = "Economics" },
                new Genre { Name = "Family & Health" },
                new Genre { Name = "Food & Drinks" },
                new Genre { Name = "History & Archaeology" },
                new Genre { Name = "Home & Garden" },
                new Genre { Name = "Languages" },
                new Genre { Name = "Medicine & Hobbies" },
                new Genre { Name = "Movie, Radio & TV" },
                new Genre { Name = "Philosophy & Religion" },
                new Genre { Name = "Society & Politics" },
                new Genre { Name = "Other" },
            };

            var authors = new List<Author>
            {
                new Author { Name = "Data daniel" },
                new Author { Name = "Karl Marx" },
                new Author { Name = "Daniel Goldberg, Linus Larsson" },

            };

            new List<Book>
            {
                new Book { Title = "The Communist Manifesto", Genre = genres.Single(g => g.Name == "Society & Politics"), Price = 7.99M, Quantity = 3000, Author = authors.Single(a => a.Name == "Karl Marx"), BookArtUrl = "/Content/Images/placeholder.jpg" },
                new Book { Title = "The DD style of life", Genre = genres.Single(g => g.Name == "Data & IT"), Price = 8.99M, Quantity = 0, Author = authors.Single(a => a.Name == "Data daniel"), BookArtUrl = "/Content/Images/placeholder.jpg" },
                new Book { Title = "Svenska Hackare", Genre = genres.Single(g => g.Name == "Data & IT"), Price = 9.99M, Quantity = 2, Author = authors.Single(a => a.Name == "Daniel Goldberg, Linus Larsson"), BookArtUrl = "/Content/Images/svenska-hackare-en-berattelse-fran-natets-skuggsida.jpg" },
                new Book { Title = "The Communist Manifesto", Genre = genres.Single(g => g.Name == "Society & Politics"), Price = 7.99M, Quantity = 3000, Author = authors.Single(a => a.Name == "Karl Marx"), BookArtUrl = "/Content/Images/placeholder.jpg" },
                new Book { Title = "The DD style of life", Genre = genres.Single(g => g.Name == "Data & IT"), Price = 8.99M, Quantity = 0, Author = authors.Single(a => a.Name == "Data daniel"), BookArtUrl = "/Content/Images/placeholder.jpg" },
                new Book { Title = "Svenska Hackare", Genre = genres.Single(g => g.Name == "Data & IT"), Price = 9.99M, Quantity = 2, Author = authors.Single(a => a.Name == "Daniel Goldberg, Linus Larsson"), BookArtUrl = "/Content/Images/svenska-hackare-en-berattelse-fran-natets-skuggsida.jpg" },
                new Book { Title = "The Communist Manifesto", Genre = genres.Single(g => g.Name == "Society & Politics"), Price = 7.99M, Quantity = 3000, Author = authors.Single(a => a.Name == "Karl Marx"), BookArtUrl = "/Content/Images/placeholder.jpg" },
                new Book { Title = "The DD style of life", Genre = genres.Single(g => g.Name == "Data & IT"), Price = 8.99M, Quantity = 0, Author = authors.Single(a => a.Name == "Data daniel"), BookArtUrl = "/Content/Images/placeholder.jpg" },
                new Book { Title = "Svenska Hackare", Genre = genres.Single(g => g.Name == "Data & IT"), Price = 9.99M, Quantity = 2, Author = authors.Single(a => a.Name == "Daniel Goldberg, Linus Larsson"), BookArtUrl = "/Content/Images/svenska-hackare-en-berattelse-fran-natets-skuggsida.jpg" },
            }.ForEach(a => context.Books.Add(a));
        }
    }
}